#! /bin/bash
# A little script I whipped up to make it easy to
# patch source trees and have sane error handling
# -Erik
#
# (c) 2002 Erik Andersen <andersen@codepoet.org>

# Set directories from arguments, or use defaults.
targetdir=${1-.}
patchdir=${2-../kernel-patches}

if [ ! -d "${targetdir}" ] ; then
    echo "Aborting.  '${targetdir}' is not a directory."
    exit 1
fi
if [ ! -d "${patchdir}" ] ; then
    echo "Aborting.  '${patchdir}' is not a directory."
    exit 1
fi

# Get absolute path
basedir=`dirname ${patchdir}`
cd ${basedir}
patch_dir_base=`pwd`
patch_dir_name=${patch_dir_base}/`basename ${patchdir}`
echo ${patch_dir_name}

# Make symbol link for patching
cd ${targetdir}
ln -s ${patch_dir_name} patches
quilt push -a

rm -f patches
